# Maintainer: David Runge <dvzrv@archlinux.org>

_name=atpublic
pkgname=python-atpublic
pkgver=4.0
pkgrel=1
pkgdesc="@public decorator for Python"
arch=(any)
url="https://gitlab.com/warsaw/public"
license=(Apache)
depends=(python)
makedepends=(
  python-build
  python-installer
  python-pdm-backend
)
checkdepends=(
  python-pytest
  python-sybil
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('2f338d3ae11d15e9ffe26881fab1c183154b9a0a7a66532a5eb39d1d48d41548078826875247c94f3853925bc1df2b8f86f4ed94533a8e58aa98de148cf5639c')
b2sums=('d8cecb083ca467d2856c0d7ae01dc4e161c31179f08c79d7b0b4650d9a3e32e15673d80d53d6851d70a4605eda8e41ba23d60be452209f96e995d632acfe5b29')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv -c /dev/null
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
}
